<template>
    <div class="order-wrap">
        <headerNav :title="title"/>
        <div class="li" v-if="list.length">
            <div class="time">{{settleMonth}}</div>
            <div class="box" v-for="(item, index) in list" :key="index" @click="toList(item)">
                <div v-if="routeType === 'bonus'">
                    <div class="item">
                        <span>级别</span>
                        <span><b>{{item.userLevelName}}</b></span>
                    </div>
                    <div class="item">
                        <span>级别数</span>
                        <span><b>{{item.levelNum}}</b></span>
                    </div>
                    <div class="item">
                        <span>级别总数</span>
                        <span><b>{{item.totalLevelNum}}</b></span>
                    </div>
                    <div class="item">
                        <span>订单数</span>
                        <span><b>{{item.orderNum}}</b></span>
                    </div>
                    <div class="item">
                        <span>订单总数</span>
                        <span><b>{{item.totalOrderNum}}</b></span>
                    </div>
                    <div class="item">
                        <span>公司当期利润</span>
                        <span><b>{{item.compProfitAmt}}</b></span>
                    </div>
                    <div class="item">
                        <span>销售应得</span>
                        <span><b>{{item.saleBonus}}</b></span>
                    </div>
                    <div class="item">
                        <span>级别应得</span>
                        <span><b>{{item.levelBonus}}</b></span>
                    </div>
                     <div class="item">
                        <span>当期应得</span>
                        <span><b>{{item.profitAmt}}</b></span>
                    </div>
                </div>   
                <div v-else>
                    <div class="item">
                        <span>费用项</span>
                        <span><b>{{item.itemName}}</b></span>
                    </div>
                    <div class="item">
                        <span>分润比例</span>
                        <span><b>{{item.profitPercent}}</b></span>
                    </div>
                    <div class="item">
                        <span>金额</span>
                        <span><b>{{item.tradeAmt}}</b></span>
                    </div>
                    <div class="item">
                        <span>分润金额</span>
                        <span><b>{{item.profitAmt}}</b></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="empty" v-else>暂无数据</div>
        <navigate />

    </div>
</template>

<script>
import {bonusDetail, profitDetail} from "../../api/page.js"

export default {
    data() {
        return {
            settleMonth: this.$route.query.date,
            routeType: this.$route.query.type ,
            title: "",
            list: []
        };
    },
    created() {
         this.routeType=this.$route.query.type
        if (this.$route.query.type === "bonus") {
            this.title = "分红明细单"
        } else {
            this.title = "分润明细单"
        }
        this.getDetailData(this.$route.query.type)
    },
    methods: {
        getDetailData(type) {
            let params = {
                dateBegin: this.settleMonth + " 00:00:00",
                dateEnd: this.settleMonth + " 23:59:59",
                pageNum: 1,
                pageSize: 100
            }
            if (type === "bonus") {
                bonusDetail(params).then(res => {
                    this.list = res.data.list
                })
            } else {
                profitDetail(params).then(res => {
                    this.list = res.data.list
                })
            }

        }
    }
};
</script>

<style scoped lang="less">
    .empty {
        position: relative;
        top: 2.666667rem;
        text-align: center;
        font-size: 0.426667rem;
    }
    .li {
        font-size: 0.4rem;
        height: 3.066667rem;
        box-sizing: border-box;
        padding-top: 1.546667rem;
        background: #fff;
        .time {
            width: 2.28rem;
            background: #F1F1F1;
            border-radius: 0.253333rem;
            font-size: 0.32rem;
            color: #343434;
            height: 0.506667rem;
            margin-left: 0.386667rem;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .box {
            font-size: 0.48rem;
            .item {
                padding: 0 0.386667rem;
                height: 1.146667rem;
                display: flex;
                justify-content: space-between;
                align-items: center;
                border-bottom: 0.026667rem solid transparent;
                border-image: linear-gradient(to bottom,transparent 50%, #e5e5e5 50%) 0 0 100%/0.026667rem 0;
                span {
                    font-size: 0.4rem;
                    display: flex;
                    justify-content: center;
                    align-items: baseline;
                    b {
                        margin-left: 0.266667rem;
                    }
                }
            }
        }

    }
</style>
